﻿<Application x:Class="MVVMAppIDataErrorInfo.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:vm="clr-namespace:MVVMAppIDataErrorInfo.ViewModel"
             StartupUri="MainWindow.xaml"
             mc:Ignorable="d">

    <Application.Resources>
        <!--Global View Model Locator-->
        <vm:ViewModelLocator x:Key="Locator"
                             d:IsDataSource="True" />

        <ControlTemplate x:Key="ValidationErrorTemplate">
            <Border BorderBrush="Blue" BorderThickness="2">
                <AdornedElementPlaceholder />
            </Border>
        </ControlTemplate>
        <Style TargetType="TextBox">
            <Style.Setters>
                <Setter Property="Validation.ErrorTemplate"
                        Value="{StaticResource ValidationErrorTemplate}" />
            </Style.Setters>
            <Style.Triggers>
                <Trigger Property="Validation.HasError" Value="true">
                    <Setter Property="ToolTip">
                        <Setter.Value>
                            <Binding 
                                RelativeSource="{x:Static RelativeSource.Self}"
                                Path="(Validation.Errors)[0].ErrorContent" />
                        </Setter.Value>
                    </Setter>

                </Trigger>
            </Style.Triggers>
        </Style>
    </Application.Resources>

</Application>
